import request from '@/utils/request';
// 请求全部封装在这里面
// 其他页面按需导入 import { a, b } from '@/api';

/* 封装get请求模板 */
export const getbanner = (params) => {
  return request({
    method: 'get',
    url: '/getbanner',
    params,
  });
};
export const getgoodscategory = (params) => {
  return request({
    method: 'get',
    url: '/getgoodscategory',
    params,
  });
};
export const getbytype = (params) => {
  return request({
    method: 'get',
    url: '/getgoodsbygid',
    params,
  });
};
export const getblog = (params) => {
  return request({
    method: 'get',
    url: '/getblog',
    params,
  });
};
export const getHotSale = (params) => {
  return request({
    method: 'get',
    url: '/getgoodsbyrandom',
    params,
  });
};
export const getgoodsbybid = (bid) => {
  return request({
    method: 'get',
    url: `/getgoodsbybid?bid=${bid}`,
  });
};
//注册
export const reg = ({ email, pwd }) => {
  return request({
    method: 'post',
    url: '/reg',
    data: { email, pwd },
  });
};
//判断是否已注册
export const checkemail = (email) => {
  return request({
    method: 'get',
    url: '/checkemail',
    params: email,
  });
};
//登录
export const login = ({ email, pwd }) => {
  return request({
    method: 'post',
    url: '/login',
    data: { email, pwd },
  });
};
//发送商品评论
export const pushcomment = (data) => {
  return request({
    method: 'post',
    url: '/addpubliccomment',
    data,
  });
};
//发送博客评论
export const pushblogcomment = (data) => {
  return request({
    method: 'post',
    url: '/addcomment',
    data,
  });
};
//购买支付
export const payfor = (data) => {
  return request({
    method: 'post',
    url: '/api/payment',
    data,
  });
};
//发送订单信息
export const payinfo = (data) => {
  return request({
    method: 'post',
    url: '/api/getresult',
    data,
  });
};
//查询订单

export const getorder = (email) => {
  return request({
    method: 'get',
    url: '/getorderbyemail',
    params: email,
  });
};
// 博客评论详情
export const getComment = () => {
  return request({
    method: 'get',
    url: '/getcomment',
  });
};
//获取商品评论
export const getGoodsComment = () => {
  return request({
    method: 'get',
    url: '/getpubliccomment',
  });
};
export const getblogcontent = (params) => {
  return request({
    method: 'get',
    url: '/getblogbyid',
    params,
  });
};
export const getdetail = (params) => {
  return request({
    method: 'get',
    url: '/getgoodsbyid',
    params,
  });
};
//模糊查询商品
export const getgoodsbycontent = (params) => {
  return request({
    method: 'get',
    url: '/getgoodsbycontent',
    params,
  });
};
//区间搜索
// export const getgoodsbyprice = ({ min, max }) => {
//   return request({
//     method: 'get',
//     url: '/getgoodsbyprice',
//     params: { min, max },
//   })
// }

//价格区间筛选商品

export const getgoodsbyprice = (min, max) => {
  return request({
    method: 'get',
    url: `/getgoodsbyprice?min=${min}&max=${max}`,
  });
};
